package com.room.search.repository;

import com.room.search.domain.RoomCommunity;
import com.room.search.domain.RoomGoods;
import com.room.search.domain.enumeration.BkRoomTypeEnum;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.*;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

/**
 * Spring Data SQL repository for the RoomGoods entity.
 */
@SuppressWarnings("unused")
@Repository
public interface RoomGoodsRepository extends JpaRepository<RoomGoods, Long>,JpaSpecificationExecutor<RoomGoods> {

    Optional<RoomGoods> findByCommunityAndBkNo(RoomCommunity community, String bkNo);

//    首页二手房
    List<RoomGoods> findAllByProvinceAndCityAndBkRoomType(String province, String city, BkRoomTypeEnum typeEnum, Pageable pageable);

    List<RoomGoods> findAllByCommunityAndBkRoomType(RoomCommunity community, BkRoomTypeEnum bkRoomTypeEnum);


    List<RoomGoods> findByCityAndDistrictLikeAndIdIn(String city, String district, Iterable<Long> ids);


    List<RoomGoods> findAllByCityAndDistrictLikeAndBkRoomType(String city, String district, BkRoomTypeEnum typeEnum);

}
